home *** CD-ROM | disk | FTP | other *** search
Wrap
import com.siemens.mp.game.MelodyComposer; import com.siemens.mp.game.Vibrator; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.util.Random; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Font; import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image; import javax.microedition.rms.RecordStore; final class CoherenceCanvas extends Canvas implements CommandListener, Runnable { private byte[] board; private byte[] undoBoard; private Image[] image; private Image logo; private Image goi; private Image tti; private Image mrgi; private Image hsi; // $FF: renamed from: db javax.microedition.lcdui.Image private Image field_0; private Graphics dbg; // $FF: renamed from: x byte private byte field_1; // $FF: renamed from: y byte private byte field_2; private boolean carrying; // $FF: renamed from: pX byte private byte field_3; // $FF: renamed from: pY byte private byte field_4; private int game_score; private boolean gameOver; private boolean canUndo; private boolean reset; private int undo_score; private int high_score; private Coherence midlet; private int xpad; private int xpad2; private int ypad; private int ypad2; private Object obj; private Command undoCommand = new Command("Undo", 1, 1); private Command startCommand = new Command("Start", 1, 21); private Command restartCommand = new Command("Restart", 1, 21); private Command soundCommand = new Command("Sound: ON", 1, 24); private Command vibraCommand = new Command("Vibrator: ON", 1, 25); private Command helpCommand = new Command("Help", 1, 27); private Command aboutCommand = new Command("About", 1, 30); private Command exitCommand = new Command("Exit", 7, 60); private static String helpString = "Your goal is to arrange identical marbles into rows of five or more to remove them from the board. Rows can be horizontal, vertical or diagonal. White marbles function as any color. Marbles can be moved anywhere on the board, but only if the route is not blocked by other marbles. Three marbles are placed randomly on the board every turn when you do not succeed in creating a row. The game is over when the board is full.\nMove cursor: Arrow keys\nSelect/drop: Enter\n"; private int state; // $FF: renamed from: bt byte[] private byte[] field_5; private int blink; private byte type = 101; private Font font; private int bgColor; // $FF: renamed from: hc boolean private boolean field_6; // $FF: renamed from: w int private int field_7; // $FF: renamed from: h int private int field_8; // $FF: renamed from: w2 int private int field_9; // $FF: renamed from: h2 int private int field_10; private boolean paused; Thread thread; private MelodyComposer melodyComposer; private boolean playSound = true; private boolean useVibrator = true; private boolean tunnariPlayed = false; private static int[][] melodyRemoveLines = new int[][]{{36, 4}, {40, 4}, {43, 3}, {48, 4}, {50, 4}, {52, 3}}; private static int[][] melodySetPiece = new int[][]{{36, 4}, {40, 4}, {48, 4}}; private static int[][] melodyMovePiece = new int[][]{{36, 5}}; private static int[][] melodyPickPiece = new int[][]{{43, 5}, {52, 5}}; private static int[][] melodyDropPieceFalse = new int[][]{{45, 5}, {33, 4}}; private static int[][] melodyUndoMove = new int[][]{{40, 5}, {40, 5}, {58, 5}, {36, 4}}; private static int[][] melodyTunnari = new int[][]{{52, 4}, {58, 4}, {52, 4}, {58, 4}, {52, 4}, {58, 4}, {40, 4}, {58, 4}, {52, 4}, {52, 4}, {58, 4}, {43, 4}, {55, 4}, {52, 4}, {40, 4}}; private static int[][] melodyFanfaari = new int[][]{{36, 5}, {58, 5}, {40, 5}, {40, 5}, {48, 4}}; private static int[][] melodyGameOver = new int[][]{{47, 5}, {43, 5}, {45, 5}, {41, 5}, {43, 5}, {40, 5}, {41, 5}, {38, 5}, {40, 5}, {36, 4}}; String[] hsn = new String[10]; int[] hss = new int[10]; int drawThis; int key; // $FF: renamed from: kp boolean boolean field_11; boolean[] poista = new boolean[70]; static final int[] dirs = new int[]{-1, -1, 0, -1, 1, -1, 1, 0, -1, 0, -1, 1, 0, 1, 1, 1}; boolean[] closed = new boolean[70]; static Random rnd0 = new Random(); CoherenceCanvas(Coherence var1) { this.midlet = var1; this.board = new byte[70]; this.undoBoard = new byte[70]; this.image = new Image[8]; this.field_5 = new byte[70]; this.field_7 = ((Canvas)this).getWidth(); this.field_8 = ((Canvas)this).getHeight(); this.field_9 = this.field_7 >> 1; this.field_10 = this.field_8 >> 1; this.font = Font.getFont(64, 0, 8); this.field_6 = Display.getDisplay(var1).isColor(); this.bgColor = 16777215; this.melodyComposer = new MelodyComposer(); ((Displayable)this).setCommandListener(this); this.thread = new Thread(this); this.thread.start(); } public void run() { // $FF: Couldn't be decompiled } public void commandAction(Command var1, Displayable var2) { this.pause(); if (var1 == this.undoCommand) { this.undoMove(); } else if (var1 == this.startCommand) { this.key = 0; this.field_11 = true; Object var3 = this.obj; synchronized(var3) { this.obj.notifyAll(); } } else if (var1 == this.restartCommand) { this.reset = true; this.type = 102; Object var11 = this.obj; synchronized(var11) { this.obj.notifyAll(); } } else if (var1 == this.soundCommand) { this.setSound(!this.playSound); } else if (var1 == this.vibraCommand) { this.setVibrator(!this.useVibrator); } else if (var1 == this.exitCommand) { this.thread = null; Object var12 = this.obj; synchronized(var12) { this.obj.notifyAll(); } this.type = 102; try { this.saveGame(); } catch (Exception var7) { } this.midlet.destroyApp(false); this.midlet.notifyDestroyed(); } else if (var1 == this.aboutCommand) { Alert var13 = new Alert("Coherence"); var13.setTimeout(-2); var13.setString("Copyright 2001 Mr. Goodliving Ltd."); this.midlet.display.setCurrent(var13); } else if (var1 == this.helpCommand) { Alert var14 = new Alert("Welcome to Coherence!"); var14.setTimeout(-2); var14.setString(helpString); this.midlet.display.setCurrent(var14); } this.myPaint(); this.resume(); } protected void hideNotify() { this.pause(); } protected void showNotify() { this.resume(); this.myPaint(); } private void saveGame() throws Exception { Object var1 = null; RecordStore var6 = RecordStore.openRecordStore("CoherenceScores", true); ByteArrayOutputStream var2 = new ByteArrayOutputStream(); DataOutputStream var3 = new DataOutputStream(var2); var3.writeBoolean(this.playSound); var3.writeBoolean(this.useVibrator); var3.writeBoolean(this.gameOver); if (!this.gameOver) { var3.write(this.board, 0, this.board.length); var3.writeInt(this.game_score); } for(int var4 = 0; var4 < 10; ++var4) { var3.writeUTF(this.hsn[var4]); var3.writeInt(this.hss[var4]); } byte[] var5 = var2.toByteArray(); if (var6.getNumRecords() == 1) { var6.setRecord(1, var5, 0, var5.length); } else { var6.addRecord(var5, 0, var5.length); } var6.closeRecordStore(); } private void loadGame() throws Exception { Object var1 = null; RecordStore var6 = RecordStore.openRecordStore("CoherenceScores", false); byte[] var2 = var6.getRecord(1); ByteArrayInputStream var3 = new ByteArrayInputStream(var2); DataInputStream var4 = new DataInputStream(var3); this.setSound(var4.readBoolean()); this.setVibrator(var4.readBoolean()); if (!var4.readBoolean()) { var4.read(this.board); this.game_score = var4.readInt(); } for(int var5 = 0; var5 < 10; ++var5) { this.hsn[var5] = var4.readUTF(); this.hss[var5] = var4.readInt(); } var6.closeRecordStore(); } private void udHsIm() { Graphics var1 = this.hsi.getGraphics(); var1.setColor(this.bgColor); var1.fillRect(0, 0, this.hsi.getWidth(), this.hsi.getHeight()); var1.setFont(this.font); var1.setColor(0); int var2 = this.font.stringWidth("10."); int var3 = this.font.getHeight(); int var4 = 0; for(int var5 = 0; var5 < 10; ++var5) { var1.drawString(this.hsn[var5], var2 + 1, var4, 20); var1.drawString("" + this.hss[var5], this.field_7 - 4, var4, 24); var1.drawString(var5 + 1 + ".", var2, var4, 24); var4 += var3; } } private void myPaint() { if (((Displayable)this).isShown()) { this.drawThis = 0; ((Canvas)this).repaint(); ((Canvas)this).serviceRepaints(); try { while(this.thread != null && this.drawThis != 0) { Thread.sleep(5L); } } catch (Exception var2) { } } } private void myPaint(int var1) { if (((Displayable)this).isShown()) { this.drawThis = var1; ((Canvas)this).repaint(); ((Canvas)this).serviceRepaints(); try { while(this.thread != null && this.drawThis != 0) { Thread.sleep(5L); } } catch (Exception var3) { } } } protected synchronized void paint(Graphics var1) { var1.setClip(0, 0, this.field_7, this.field_8); label88: switch (this.drawThis) { case 0: switch (this.type) { case 0: var1.setColor(16777215); var1.fillRect(0, 0, this.field_7, this.field_8); var1.drawImage(this.mrgi, this.field_9, this.field_10, 3); break label88; case 1: if (!this.tunnariPlayed) { this.setMelody(this.melodyComposer, melodyTunnari); this.melodyComposer.setBPM(120); if (this.playSound) { this.melodyComposer.getMelody().play(); } this.tunnariPlayed = true; } var1.setColor(this.bgColor); var1.fillRect(0, 0, this.field_7, this.field_8); int var2 = this.field_8 + this.tti.getHeight() + 1 + this.hsi.getHeight(); if (this.blink > var2 - 1) { this.blink = -30; } int var3 = this.field_10; if (this.blink >= 0) { var3 -= this.blink; } ++this.blink; var1.drawImage(this.logo, this.field_9, var3, 3); var1.drawImage(this.logo, this.field_9, var3 + var2, 3); var3 += this.field_10; var1.drawImage(this.tti, this.field_9, var3, 17); var3 += this.tti.getHeight() + 2; var1.drawImage(this.hsi, this.field_9, var3, 17); break label88; case 2: this.dbg.setColor(this.bgColor); this.dbg.fillRect(0, 0, this.field_7, this.field_8); this.drawBoard(this.dbg); this.drawScore(this.dbg); var1.drawImage(this.field_0, 0, 0, 20); break label88; case 3: this.dbg.setColor(this.bgColor); this.dbg.fillRect(0, 0, this.field_7, this.field_8); this.drawBoard(this.dbg); this.drawScore(this.dbg); this.dbg.drawImage(this.goi, this.field_9, 40, 3); var1.drawImage(this.field_0, 0, 0, 20); break label88; case 101: var1.setColor(16777215); var1.fillRect(0, 0, this.field_7, this.field_8); var1.setColor(0); var1.drawString("Loading...", this.field_9, this.field_10, 65); break label88; case 102: var1.setColor(16777215); var1.fillRect(0, 0, this.field_7, this.field_8); default: break label88; } case 1: for(byte var4 = 0; var4 < 7; ++var4) { for(byte var9 = 0; var9 < 10; ++var9) { if (this.field_5[var4 * 10 + var9] != 0) { var1.setClip(this.xpad2 + var9 * 9, this.ypad2 + var4 * 9, 10, 10); var1.drawImage(this.image[0], this.xpad, this.ypad, 20); } } } break; case 2: for(byte var5 = 0; var5 < 7; ++var5) { for(byte var6 = 0; var6 < 10; ++var6) { if (this.field_5[var5 * 10 + var6] != 0) { var1.drawImage(this.image[this.field_5[var5 * 10 + var6]], this.xpad2 + 1 + var6 * 9, this.ypad2 + 1 + var5 * 9, 20); } } } break; case 3: var1.setClip(this.xpad2 + this.field_1 * 9, this.ypad2 + this.field_2 * 9, 10, 10); this.drawBoard(var1); break; case 4: var1.setClip(this.xpad2 + this.field_1 * 9, this.ypad2 + this.field_2 * 9, 10, 10); this.drawBoard(var1); if (this.carrying) { var1.drawImage(this.image[this.board[this.field_4 * 10 + this.field_3]], this.xpad2 + 1 + this.field_1 * 9, this.ypad2 + 1 + this.field_2 * 9, 20); } var1.setColor(0); var1.drawRect(this.xpad2 + this.field_1 * 9, this.ypad2 + this.field_2 * 9, 9, 9); break; case 5: this.drawBoard(var1); break; case 6: var1.setClip(this.xpad2 + this.field_3 * 9, this.ypad2 + this.field_4 * 9, 10, 10); this.drawBoard(var1); break; case 7: var1.setColor(0); var1.drawRect(this.xpad2 + this.field_3 * 9, this.ypad2 + this.field_4 * 9, 9, 9); break; case 8: this.drawScore(var1); break; case 9: var1.setColor(this.bgColor); var1.fillRect(0, 0, this.field_7, this.field_8); break; case 10: var1.setClip(this.xpad2 + this.field_1 * 9, this.ypad2 + this.field_2 * 9, 10, 10); this.drawBoard(var1); var1.setColor(0); var1.drawRect(this.xpad2 + 1 + this.field_1 * 9, this.ypad2 + 1 + this.field_2 * 9, 7, 7); } this.drawThis = 0; } private void drawBoard(Graphics var1) { var1.drawImage(this.image[0], this.xpad, this.ypad, 20); int var2 = var1.getClipX() - 9; int var3 = var2 + var1.getClipWidth() + 9; int var4 = var1.getClipY() - 9; int var5 = var4 + var1.getClipHeight() + 9; for(byte var6 = 0; var6 < 7; ++var6) { for(byte var7 = 0; var7 < 10; ++var7) { int var8 = this.xpad2 + 1 + var7 * 9; int var9 = this.ypad2 + 1 + var6 * 9; if (this.board[var6 * 10 + var7] > 0 && var8 >= var2 && var9 >= var4 && var8 <= var3 && var9 <= var5) { var1.drawImage(this.image[this.board[var6 * 10 + var7]], var8, var9, 20); } } } } private void drawScore(Graphics var1) { var1.setClip(0, this.ypad + 76 - this.font.getBaselinePosition(), this.field_7, this.font.getHeight()); var1.drawImage(this.image[0], this.xpad, this.ypad, 20); var1.setColor(0); var1.drawString("Score: " + this.game_score, this.field_9, this.ypad + 76, 65); var1.setClip(0, 0, this.field_7, this.field_8); } private void undoMove() { if (this.canUndo) { this.setMelody(this.melodyComposer, melodyUndoMove); this.melodyComposer.setBPM(200); if (this.playSound) { this.melodyComposer.getMelody().play(); } System.arraycopy(this.undoBoard, 0, this.board, 0, this.undoBoard.length); this.game_score = this.undo_score; this.canUndo = false; } } private void newGame() { for(int var1 = 0; var1 < this.board.length; ++var1) { this.board[var1] = 0; } this.carrying = false; for(int var2 = 0; var2 < 9 && !this.checkFull(); ++var2) { int var3 = rnd() % 10; int var4 = rnd() % 7; if (this.board[var4 * 10 + var3] == 0) { this.board[var4 * 10 + var3] = (byte)(rnd() % 7 + 1); } } this.canUndo = false; this.gameOver = false; this.game_score = 0; for(int var5 = 0; var5 < this.field_5.length; ++var5) { this.field_5[var5] = 0; } } private void keys() { if (this.key == 1) { --this.field_1; if (this.field_1 < 0) { this.field_1 = 0; } } else if (this.key == 2) { ++this.field_1; if (this.field_1 > 9) { this.field_1 = 9; } } else if (this.key == 3) { ++this.field_2; if (this.field_2 > 6) { this.field_2 = 6; } } else if (this.key == 4) { --this.field_2; if (this.field_2 < 0) { this.field_2 = 0; } } else if (this.key == 0) { this.key = -1; if (this.carrying) { if (this.field_1 == this.field_3 && this.field_2 == this.field_4) { this.carrying = false; this.setMelody(this.melodyComposer, melodyUndoMove); this.melodyComposer.setBPM(200); if (this.playSound) { this.melodyComposer.getMelody().play(); } } else if (this.tryMove()) { this.carrying = false; this.setMelody(this.melodyComposer, melodyPickPiece); this.melodyComposer.setBPM(200); if (this.playSound) { this.melodyComposer.getMelody().play(); } if (this.useVibrator) { Vibrator.triggerVibrator(50); } this.myPaint(3); this.myPaint(6); if (!this.checkLines() && this.newTurn()) { this.setMelody(this.melodyComposer, melodyGameOver); this.melodyComposer.setBPM(140); if (this.playSound) { this.melodyComposer.getMelody().play(); } this.gameOver = true; this.type = 2; this.canUndo = false; } this.myPaint(8); } else { this.setMelody(this.melodyComposer, melodyDropPieceFalse); this.melodyComposer.setBPM(200); if (this.playSound) { this.melodyComposer.getMelody().play(); } } } else if (this.board[this.field_2 * 10 + this.field_1] != 0) { this.setMelody(this.melodyComposer, melodyPickPiece); this.melodyComposer.setBPM(200); if (this.playSound) { this.melodyComposer.getMelody().play(); } if (this.useVibrator) { Vibrator.triggerVibrator(50); } this.field_3 = this.field_1; this.field_4 = this.field_2; this.carrying = true; } } } private boolean isKeyPressed() { return this.key >= 0; } protected void pause() { this.paused = true; } protected void resume() { this.paused = false; Object var1 = this.obj; synchronized(var1) { this.obj.notifyAll(); } } private void waitForAnyKey(int var1) throws Exception { while(this.paused) { Object var2 = this.obj; synchronized(var2) { this.obj.wait(); } if (this.thread == null) { throw new Exception(); } } Object var7 = this.obj; synchronized(var7) { this.obj.notifyAll(); this.obj.wait((long)var1); } if (this.thread == null) { throw new Exception(); } } private void waitForKey(int var1) throws Exception { while(this.paused) { Object var2 = this.obj; synchronized(var2) { this.obj.wait(); } if (this.thread == null) { throw new Exception(); } } if (this.key < 0) { Object var7 = this.obj; synchronized(var7) { this.obj.wait((long)var1); } } if (this.thread == null) { throw new Exception(); } } private void waitForKeyRelease(int var1) throws Exception { while(this.paused) { Object var2 = this.obj; synchronized(var2) { this.obj.wait(); } if (this.thread == null) { throw new Exception(); } } if (this.key >= 0) { Object var7 = this.obj; synchronized(var7) { this.obj.wait((long)var1); } } if (this.thread == null) { throw new Exception(); } } protected void keyPressed(int var1) { this.key = -1; this.field_11 = true; switch (((Canvas)this).getGameAction(var1)) { case 1: this.key = 4; break; case 2: this.key = 1; case 3: case 4: case 7: default: break; case 5: this.key = 2; break; case 6: this.key = 3; break; case 8: this.key = 0; } Object var2 = this.obj; synchronized(var2) { this.obj.notifyAll(); } } protected void keyReleased(int var1) { this.field_11 = false; this.key = -1; Object var2 = this.obj; synchronized(var2) { this.obj.notifyAll(); } } private void checkHiScore() { for(int var1 = 0; var1 < this.hss.length; ++var1) { if (this.hss[var1] <= this.game_score) { for(int var2 = 9; var2 > var1; --var2) { this.hsn[var2] = this.hsn[var2 - 1]; this.hss[var2] = this.hss[var2 - 1]; } this.hsn[var1] = this.midlet.getName(); this.hss[var1] = this.game_score; return; } } } private boolean checkLines() { for(int var1 = 0; var1 < this.poista.length; ++var1) { this.poista[var1] = false; } for(int var2 = 0; var2 < 7; ++var2) { for(int var3 = 0; var3 < 10; ++var3) { byte var4 = this.board[var2 * 10 + var3]; if (var4 != 0) { for(int var5 = 0; var5 < 8; ++var5) { var4 = this.board[var2 * 10 + var3]; int var6 = 0; boolean var7 = false; int var8 = var3; for(int var9 = var2; !var7; var9 += dirs[var5 * 2 + 1]) { if (var9 <= 6 && var9 >= 0 && var8 <= 9 && var8 >= 0) { if (var4 == 1 && this.board[var9 * 10 + var8] != 0) { var4 = this.board[var9 * 10 + var8]; } if (this.board[var9 * 10 + var8] != var4 && this.board[var9 * 10 + var8] != 1) { var7 = true; } else { ++var6; } } else { var7 = true; } var8 += dirs[var5 * 2 + 0]; } if (var6 >= 5) { for(int var10 = 0; var10 < var6; ++var10) { this.poista[(var2 + var10 * dirs[var5 * 2 + 1]) * 10 + var3 + var10 * dirs[var5 * 2 + 0]] = true; } } } } } } boolean var12 = false; int var14 = 0; for(int var15 = 0; var15 < 7; ++var15) { for(int var16 = 0; var16 < 10; ++var16) { if (this.poista[var15 * 10 + var16]) { var12 = true; var14 += 5; this.game_score += 5 + var14; this.field_5[var15 * 10 + var16] = this.board[var15 * 10 + var16]; this.board[var15 * 10 + var16] = 0; } } } if (var12) { this.setMelody(this.melodyComposer, melodyRemoveLines); this.melodyComposer.setBPM(200); if (this.playSound) { this.melodyComposer.getMelody().play(); } if (this.useVibrator) { Vibrator.triggerVibrator(250); } try { for(int var17 = 0; var17 < 5; ++var17) { this.waitForKey(50); this.myPaint(2); this.waitForKey(50); this.myPaint(1); } } catch (Exception var11) { } for(int var18 = 0; var18 < this.field_5.length; ++var18) { this.field_5[var18] = 0; } } return var12; } private boolean checkFull() { for(int var1 = 0; var1 < this.board.length; ++var1) { if (this.board[var1] == 0) { return false; } } return true; } private boolean newTurn() { for(int var1 = 0; var1 < this.board.length; ++var1) { if (this.field_5[var1] == 2) { this.board[var1] = 0; this.field_5[var1] = 0; } } for(int var2 = 0; var2 < 3; ++var2) { if (this.checkFull()) { return true; } int var3; int var4; do { var3 = rnd() % 10; var4 = rnd() % 7; } while(this.board[var4 * 10 + var3] != 0); this.board[var4 * 10 + var3] = (byte)(rnd() % 7 + 1); this.field_5[var4 * 10 + var3] = this.board[var4 * 10 + var3]; } try { for(int var6 = 0; var6 < 2; ++var6) { this.waitForKey(50); this.myPaint(1); this.waitForKey(50); this.myPaint(2); } } catch (Exception var5) { } for(int var7 = 0; var7 < this.field_5.length; ++var7) { this.field_5[var7] = 0; } return this.checkFull(); } private boolean tryMove() { if (this.checkPath(this.field_3, this.field_4, this.field_1, this.field_2)) { System.arraycopy(this.board, 0, this.undoBoard, 0, this.board.length); this.undo_score = this.game_score; this.canUndo = true; this.board[this.field_2 * 10 + this.field_1] = this.board[this.field_4 * 10 + this.field_3]; this.board[this.field_4 * 10 + this.field_3] = 0; return true; } else { return false; } } private boolean checkPath(int var1, int var2, int var3, int var4) { for(int var5 = 0; var5 < this.board.length; ++var5) { if (this.board[var5] == 0) { this.closed[var5] = false; } else { this.closed[var5] = true; } } return this.checkPoint(var1, var2, var3, var4); } private boolean checkPoint(int var1, int var2, int var3, int var4) { this.closed[var2 * 10 + var1] = true; if (var1 == var3 && var2 == var4) { return true; } else if (var2 < 6 && !this.closed[(var2 + 1) * 10 + var1] && this.checkPoint(var1, var2 + 1, var3, var4)) { return true; } else if (var1 < 9 && !this.closed[var2 * 10 + var1 + 1] && this.checkPoint(var1 + 1, var2, var3, var4)) { return true; } else if (var2 > 0 && !this.closed[(var2 - 1) * 10 + var1] && this.checkPoint(var1, var2 - 1, var3, var4)) { return true; } else { return var1 > 0 && !this.closed[var2 * 10 + (var1 - 1)] && this.checkPoint(var1 - 1, var2, var3, var4); } } public void setMelody(MelodyComposer var1, int[][] var2) { var1.resetMelody(); for(int var3 = 0; var3 < var2.length; ++var3) { try { var1.appendNote(var2[var3][0], var2[var3][1]); } catch (Exception var5) { } } } public void setSound(boolean var1) { this.playSound = var1; if (this.playSound) { ((Displayable)this).removeCommand(this.soundCommand); this.soundCommand = new Command("Sound: ON", 1, 24); ((Displayable)this).addCommand(this.soundCommand); } else { ((Displayable)this).removeCommand(this.soundCommand); this.soundCommand = new Command("Sound: OFF", 1, 24); ((Displayable)this).addCommand(this.soundCommand); } } public void setVibrator(boolean var1) { this.useVibrator = var1; if (this.useVibrator) { ((Displayable)this).removeCommand(this.vibraCommand); this.vibraCommand = new Command("Vibrator: ON", 1, 25); ((Displayable)this).addCommand(this.vibraCommand); } else { ((Displayable)this).removeCommand(this.vibraCommand); this.vibraCommand = new Command("Vibrator: OFF", 1, 25); ((Displayable)this).addCommand(this.vibraCommand); } } static int rnd() { return rnd0.nextInt() >>> 1; } }